home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: WindowDialog.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1990-1993 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.defs.h" /* Get various application definitions. */
- #include "App.protos.h" /* Get the prototypes for application. */
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
- /*****************************************************************************/
-
-
-
- extern RgnHandle gCursorRgn; /* We handle cursors here, so we need */
- extern CursPtr gCursorPtr; /* to know about these things. */
- /* Above are DTS.Lib..framework globals. */
-
- extern short gDialogErr; /* Error numbers to be displayed in */
- /* a dialog window of type 'ERR#' are */
- /* passed in this way. */
-
- static short gCtlNum;
-
-
-
- /*****************************************************************************/
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See CalcFrameRgn() for info. */
-
- #pragma segment TheDoc
- void DialogCalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn)
- {
- #ifndef __MWERKS__
- #pragma unused (frHndl, window, rgn)
- #endif
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See ContentClick() for info. */
-
- #pragma segment TheDoc
- void DialogContentClick(WindowPtr window, EventRecord *event, Boolean firstClick)
- {
- #ifndef __MWERKS__
- #pragma unused (firstClick)
- #endif
-
- short cnum, action;
- ControlHandle ctl;
-
- gCtlNum = cnum = IsCtlEvent(window, event, &ctl, &action);
- if ((cnum == -1) || (cnum == -2))
- if (GetButtonVariant(ctl) == pushButProc)
- DisposeOneWindow(window, kClose);
-
- return;
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See ContentKey() for info. */
-
- #pragma segment TheDoc
- Boolean DialogContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough)
- {
- #ifndef __MWERKS__
- #pragma unused (passThrough)
- #endif
-
- short cnum, action;
- ControlHandle ctl;
-
- gCtlNum = cnum = IsCtlEvent(window, event, &ctl, &action);
- if ((cnum == -1) || (cnum == -2)) {
- if (GetButtonVariant(ctl) == pushButProc) {
- DisposeOneWindow(window, kClose);
- return(true);
- }
- }
-
- #if DEV_VERSION
- if ((event->message & charCodeMask) == (unsigned char)'≥') {
- if ((event->modifiers & (optionKey | cmdKey)) == (optionKey | cmdKey)) {
- gCtlNum = -2;
- DisposeOneWindow(window, kClose);
- }
- }
- #endif
-
- return(true);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See DrawFrame() for info. */
-
- #pragma segment TheDoc
- void DialogDrawFrame(FileRecHndl frHndl, WindowPtr window, Boolean activate)
- {
- MoveTo(0, (*frHndl)->fileState.topSidebar - 1);
- LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, (*frHndl)->fileState.topSidebar - 1);
- LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, 16383);
-
- BeginFrame(window);
- DoDrawControls(window, activate);
- EndFrame(window);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See FreeDocument() for info. */
-
- #pragma segment TheDoc
- OSErr DialogFreeDocument(FileRecHndl frHndl)
- {
- return(DefaultFreeDocument(frHndl));
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See FreeWindow() for info. */
-
- #pragma segment TheDoc
- OSErr DialogFreeWindow(FileRecHndl frHndl, WindowPtr window)
- {
- #ifndef __MWERKS__
- #pragma unused (frHndl, window)
- #endif
-
- /* For dialogs that need to keep their info before getting dismissed:
- ** Check gCtlNum to see what control caused dialog dismissal.
- ** -1: Default button.
- ** -2: Cancel button.
- ** If you determine that the dialog shouldn't be dismissed after all, then
- ** return an error.
- */
-
- return(noErr);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See ImageDocument() for info. */
-
- #pragma segment TheDoc
- OSErr DialogImageDocument(FileRecHndl frHndl)
- {
- #ifndef __MWERKS__
- #pragma unused (frHndl)
- #endif
-
- WindowPtr curPort;
-
- GetPort(&curPort);
- DoDrawControls(curPort, false); /* Draw the content controls. */
-
- return(noErr);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See InitContent() for info. */
-
- #pragma segment TheDoc
- OSErr DialogInitContent(FileRecHndl frHndl, WindowPtr window)
- {
- OSErr err;
- OSType sftype;
- ControlHandle ctl;
- Str255 pstr;
-
- sftype = (*frHndl)->fileState.sfType;
- err = AddControlSet(window, sftype, kwStandardVis, 0, 0, nil);
- if (sftype == 'ERR#') {
- CNum2Ctl(window, 100, &ctl);
- if (ctl) {
- CTEGetPStr(ctl, pstr);
- pcatdec(pstr, gDialogErr);
- gDialogErr = noErr;
- CTESetPStr(ctl, pstr);
- }
- }
-
- return(err);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See ResizeContent() for info. */
-
- #pragma segment TheDoc
- void DialogResizeContent(WindowPtr window, short oldh, short oldv)
- {
- #ifndef __MWERKS__
- #pragma unused (window, oldh, oldv)
- #endif
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See ScrollFrame() for info. */
-
- #pragma segment TheDoc
- void DialogScrollFrame(FileRecHndl frHndl, WindowPtr window, long dh, long dv)
- {
- #ifndef __MWERKS__
- #pragma unused (frHndl, window, dh, dv)
- #endif
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See UndoFixup() for info. */
-
- #pragma segment TheDoc
- void DialogUndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo)
- {
- #ifndef __MWERKS__
- #pragma unused (frHndl, contOrg, afterUndo)
- #endif
-
- /* See DTS.Draw for an example of what you might do here. */
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See WindowCursor() for info. */
-
- #pragma segment TheDoc
- Boolean DialogWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt)
- {
- #ifndef __MWERKS__
- #pragma unused (frHndl, window, globalPt)
- #endif
-
- /* For examples of applications that have non-arrow cursor regions,
- ** see DTS.Chat and DTS.Draw. */
-
- DoSetCursor(&qd.arrow);
- return(true);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See WindowGoneFixup() for info. */
-
- #pragma segment TheDoc
- void DialogWindowGoneFixup(WindowPtr window)
- {
- #ifndef __MWERKS__
- #pragma unused (window)
- #endif
- }
-
-
-
- /*****************************************************************************/
- /*****************************************************************************/
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See AdjustMenuItems() for info. */
-
- #pragma segment TheDoc
- Boolean DialogAdjustMenuItems(WindowPtr window, short menuID)
- {
- #ifndef __MWERKS__
- #pragma unused (window)
- #endif
-
- if (menuID == mEdit)
- CTEEditMenu(nil, mEdit, UnmapMItem(mEdit, kStdUndo), UnmapMItem(mEdit, kStdCut));
-
- return(false);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• You don't call this. DTS.Lib..framework does for appropriate document type(s). •• */
- /* See DoMenuItem() for info. */
-
- #pragma segment TheDoc
- Boolean DialogDoMenuItem(WindowPtr window, short menuID, short menuItem)
- {
- #ifndef __MWERKS__
- #pragma unused (window)
- #endif
-
- return(DoMenuCommand(menuID, menuItem));
- }
-
-
-
-